package com.cloudptt.api.models;

import android.content.Context;

import com.cloudptt.api.product.log.Log;
import com.cloudptt.api.product.res.Resource;

public class ErrInfo {

	private String title = null;
	private int cause = -1;
//	private Context context = null;
	
	public ErrInfo(String title,int cause)
	{
		Log.e("ErrInfo", "cause="+ cause );
		this.title = title;
		this.cause = cause;
//		this.context = ctx;
	}

	public String getErrDesc()
	{
		String desc = "";
		try{
//			if(context != null )
//			{
				String key = getKey();
				Log.e("ErrInfo", "key="+ key );
				desc = Resource.getString(key);
//			}
//			else
//			{
//				desc = Resource.getString("e_undefined");//context.getResources().getString(R.string.e_undefined);
//				desc = String.format(desc, this.cause); 
//			}
		}
		catch(Exception e){
			e.printStackTrace();
			desc = Resource.getString("e_undefined");//context.getResources().getString(R.string.e_undefined);
			desc = String.format(desc, this.cause);
		}
		
		return desc;
	}
	
	private String getKey()
	{
		return "e_"+ (this.title != null ? title.toLowerCase():"") + "_" + this.cause;
	}
}
